<?php
declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/11
 * Time: 15:01
 */

namespace App\Model;

use Hyperf\Database\Model\Model;
use Hyperf\Database\Model\SoftDeletes;

class Party extends Model
{
    use SoftDeletes;

    protected ?string $table='party';
    public bool $timestamps = true;

    protected array $fillable = ['name','content','images','admin_id'];


    public function getContentAttribute($value): string
    {
        return $value != null ? htmlspecialchars_decode($value) : '';
    }

    public function setContentAttribute($value): void
    {
        if($value!='') htmlspecialchars($value);
        $this->attributes['content'] = $value;
    }


    public function setImagesAttribute($value)
    {
        $this->attributes['images'] = implode(',', $value);
    }

    public function getImagesAttribute($value): array
    {
        return $value != null ? explode(',', $value) : [];
    }
}